var handler = require('./handler.js');
var fs = require('fs');
var path = require('path');

module.exports = function (req, res) {
    if(req.url == '/') {
        handler.home(req, res);
    }else if(req.url == '/login'){
        handler.login(req, res);
    }else if(req.url == '/blogs'){
        handler.blogs(req, res);
    }else if(req.url == '/register'){
        handler.register(req, res);
    }else if(req.url == '/charu'){
        handler.charu(req, res);
    }else if(req.url == '/insert'){
        handler.insert(req, res);
    }else if(req.url == '/leave'){
        handler.leave(req, res);
    }else if(req.url.startsWith ('/delete')){
        handler.delete(req, res);
    }else if(req.url == '/blogslogin'){
        handler.blogslogin(req, res);
    }else if(req.url.startsWith('/search')){
        handler.search(req, res);
    }else if(req.url.startsWith('/find')){
        handler.find(req, res);
    }else if(req.url == '/publication'){
        handler.publication(req, res);
    }else if(req.url.startsWith('/modify')){
        handler.modify(req, res);
    }else if(req.url.startsWith('/revise')){
        handler.revise(req, res);
    }else if(req.url.startsWith('/update')){
        handler.update(req, res);
    }else if(req.url == '/logout'){
        handler.logout(req, res);
    }else{
        fs.readFile(path.join('./public', req.url), function (err, data){
            res.end(data);
        });
    }
}